import gameModel from "./gameModel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class outSideTrianleItem extends cc.Component {

    private scaleSpeed:any;
    private isDestroy:any;
    private outsideTrianglePool:any;

    start () {
        this.outsideTrianglePool=gameModel.getInstance().outsideTrianglePool;
        this.init(6,1);
    }
    init(speed,initScale){
        this.scaleSpeed=speed;//this.scaleS;
        this.node.scale = initScale;
        this.isDestroy=false;
        
    }

    update (dt) {
        if(gameModel.getInstance().isGameOver){
            this.scaleSpeed=0;
            return;
        }
        if(this.node.scale>=0.35){
            this.node.scale -=this.scaleSpeed/10*dt;
        }else if(!this.isDestroy){
            // console.error( this.outsideTrianglePool );
            // this.node.emit('getScore');
            gameModel.getInstance().Score++;
            this.outsideTrianglePool.put(this.node);
            this.isDestroy=true;
        }
    }
    
}
